package com.own.component.util.excel.handler;

import com.own.component.common.model.ExceptionMessageModel;
import com.own.component.util.excel.exception.ExcelException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * ExcelExceptionHandler
 *
 * @author chenxueli
 * @date 2021/2/26 13:56
 */
@Slf4j
@Order(1)
@RestControllerAdvice
public class ExcelExceptionHandler {

    /**
     * 处理 ExcelException 异常 （excel工具异常）
     *
     * @param e 异常信息
     * @return 返回信息
     */
    @ExceptionHandler(ExcelException.class)
    public ExceptionMessageModel handleException(ExcelException e) {
        log.error(e.getMessage());
        return new ExceptionMessageModel(e);
    }

}
